﻿package com.eitb.programas.olentzero09{
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	import flash.media.*;
	import flash.net.*;
	import flash.geom.*;

	public class DialogoOlentzero extends Sprite implements IVistaOlentzero {
		private var cOlentzero:IControladorOlentzero;

		public function DialogoOlentzero():void {
			this.cacheAsBitmap = true;
		}

		// INIT COMPONENTES
		public function initControlador(cOlentzero:IControladorOlentzero):void {
			this.cOlentzero=cOlentzero;
		}
		// INIT COMPONENTES

		// INIT PARAMETROS
		// INIT PARAMETROS

		// IVistaOlentzero
		public function setVisible(visible:Boolean):void {
			this.visible=visible;
		}
		public function getZonaColision():DisplayObject {
			return this.colision;
		}
		public function moveX(espacioX:Number):void {
			this.x+=espacioX;
		}
		public function moveY(espacioY:Number):void {
			this.y+=espacioY;
		}
		public function setX(x:Number):void {
			this.x = x;
		}
		public function setY(y:Number):void {
			this.y = y;
		}		
		public function setInBounds(limites:Object):void {
			if (this.x<limites.x) {
				this.x=limites.x;
			}
			if (this.x>limites.xMax) {
				this.x=limites.xMax;
			}
			if (this.y>limites.yMax) {
				this.y=limites.yMax;
			}
		}
		public function mira(velocidad:Number):void {
			if (velocidad<0) {
				this.scaleX=-1;
			} else {
				this.scaleX=1;
			}
		}
		public function accion(velocidad:Number):void {
			var tmp:Boolean = velocidad>-.25&&velocidad<.25;
			this.quieto.visible = tmp;
			this.corriendo.visible = !tmp;
		}
		
		public function getOlentzeroX():Number {
			return this.x;
		}
		public function getOlentzeroY():Number {
			return this.y;
		}
		
		public function getMouseX():Number {
			return stage.mouseX;
		}
		
		public function getMouseY():Number {
			return stage.mouseY;
		}
		
		public function getOlentzeroPosition():Point {
			return new Point(this.x, this.y);
		}
		public function finalize():void {
			try {
				this.parent.removeChild(this);
			} catch (e:Error) {
				trace(e);
			}		
		}
		// IVistaOlentzero
	}
}